<?php
class shop_productModel extends model{
	public $base;
	public function __construct(&$base){
		parent::__construct($base);
		$this->table="shop_product";
	}
	
	public function id_list($option){
		$data=$this->select($option);
		if($data){
			foreach($data as $k=>$v){
				$t[$v['id']]=$v;
			}
			return $t;
		}
		return false;
	}
	
	public function getListByIds($ids){
		if(!empty($ids)){
			$option['where']=" id in("._implode($ids).")";
			$data=parent::select($option);
			 
			if($data){
				$list=array();
				foreach($data as $k=>$v){
					$list[$v['id']]=$v;
				}
				return $list;
			}
		}
		return false;
	}
	
	public function total_num_add($option){
	 
		$shopid=intval($option['shopid']);
		$id=intval($option['id']);
		$total_num=intval($option['total_num']);
		$row=M("shop_product")->selectRow("shopid=".$shopid." AND id=".$id."");
		M("shop_product")->update(array(
				"total_num"=>$row['total_num']+$total_num
		),"id=".$row['id']);	
	}
	
}

?>